package concept.misc;

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.springframework.util.StringUtils;

public class PatternLab
{
	public static void main(String...strings)
	{
		//doMatcher();
		doPrintf();
	}
	static void doScanner()
	{
		String regex = "\\S\\d\\d\\d\\d-\\d\\d-\\d\\d-\\d\\d-\\d\\d-\\d\\d";
		//String filename = "BatchID_i18nChars.2009-03-06-12-33-24.xls";
		String filename = "C:\\temp\\whatever_folder\\BatchID_i18nChars.2009-03-06-12-33-24_results.xls";
		//String filename = "BatchID_i18nChars@2009-03-06-12-33-24.csv";
		//String filename = "BatchID_i18nChars.csv";
		
		Pattern p = Pattern.compile(regex);
		
		Scanner sc = new Scanner(filename);
		String str;
		/*if ((str = sc.findInLine(p))!=null)
		{
			filename=filename.replace(str, "");
		}
		System.out.printf("[%s] with [%s] been replaced. ", filename, str);*/
		
		filename = filename.replaceAll(regex, "");
		
		System.out.printf("[%s] been replaced. ", filename);
	}
	static void doMatcher()
	{
		String source = "Ahaaa, an apple!";
		String regex = "\\w*a+.*\\w+\\s";
		Pattern pattern = Pattern.compile(regex);
		Matcher matcher = pattern.matcher(source);
		while(matcher.find())
		{
			System.out.println("["+matcher.group()+"]");
		}
	}
	static void doPrintf()
	{
		double val1 = 3.91;
		double val2 = 3.95;
		int i = 3/2;
		double d = 3/2;
		double f = 3d/2f;
		System.out.printf("%.1f, %.1f, %d, %.1f\n", val1, val2, i, f);
	}
}
